package com.twu.biblioteca;

import java.util.List;

public class MovieListingOption implements CustomerOptionHandler{
    private Library library;

    public MovieListingOption(Library library) {
        this.library = library;
    }
    public String viewMovies() {
        StringBuilder movieList = new StringBuilder();
        List<Movie> movies = library.getMovies();

        for (Movie movie : movies) {
            String movieRating = movie.getMovieRating() == 0 ? "N/A" : movie.getMovieRating() + "";
            movieList.append(movie.getName() + "\t" + movie.getMovieYear() + "\t" + movie.getMovieDirector() + "\t" + movieRating + "\n");
        }
        return movieList.toString();
    }
    public String showMoviesHeading() {
        return "Movie\tYear\tDirector\tRating";
    }
    public String customerOption(){
        return showMoviesHeading() + "\n" + viewMovies();
    }
}
